/**
 * @Project Name: ${projectName}
 * @Package Name: ${projectPackageName}.start.controller.${domainName}
 * @Since JDK 1.8
 */
package ${projectPackageName}.start.controller.${domainName};

import cn.com.scgeling.framework.pagination.domain.ConditionAndPagination;
import cn.com.scgeling.framework.pagination.domain.Pagination;
import ${projectPackageName}.client.constant.${domainName}.${className}ServiceConstants;
import ${projectPackageName}.domain.dto.${domainName}.${className}DTO;
import ${projectPackageName}.infrastructure.service.${domainName}.${className}Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: ${className}ServiceController
 * @Author 胡松 hoofungson@163.com
 * @Date ${datetime}
 * @Version V1.0
 */
@Slf4j
@RequestMapping(${className}ServiceConstants.DEFAULT_URL_PREFIX)
@RestController
public class ${className}ServiceController {

    /**
     * 注入${className}Service
     **/
    @Autowired
    private ${className}Service ${lowerCaseClassName}Service;

    /**
     * 保存或更新
     *
     * @param ${lowerCaseClassName}DTO
     * @return
     **/
    @PostMapping
    public Boolean saveOrUpdate(@RequestBody ${className}DTO ${lowerCaseClassName}DTO) {
        this.${lowerCaseClassName}Service.saveOrUpdate(${lowerCaseClassName}DTO);
        return true;
    }

    /**
     * 批量保存或更新
     *
     * @param ${lowerCaseClassName}DTOList
     * @return
     **/
    @PostMapping("/batch/save-or-update")
    public Boolean batchSaveOrUpdate(@RequestBody List<${className}DTO> ${lowerCaseClassName}DTOList) {
        this.${lowerCaseClassName}Service.batchSaveOrUpdate(${lowerCaseClassName}DTOList);
        return true;
    }

    /**
     * 根据ID获取
     *
     * @param id
     * @return
     **/
    @GetMapping("/{id}")
    public ${className}DTO getById(@PathVariable("id") Long id) {
        return this.${lowerCaseClassName}Service.getById(id);
    }

    /**
     * 根据条件获取
     *
     * @param condition
     * @return
     **/
    @PostMapping("/condition")
    public ${className}DTO getByCondition(@RequestBody ${className}DTO condition) {
        return this.${lowerCaseClassName}Service.getByCondition(condition);
    }

    /**
     * 获取所有列表
     *
     * @return
     **/
    @GetMapping
    public List<${className}DTO> listAll() {
        return this.${lowerCaseClassName}Service.listAll();
    }

    /**
     * 根据条件获取列表
     *
     * @param condition
     * @return
     **/
    @GetMapping("/list/condition")
    public List<${className}DTO> findByCondition(@RequestBody ${className}DTO condition) {
        return this.${lowerCaseClassName}Service.findByCondition(condition);
    }

    /**
     * 获取分页
     *
     * @param conditionAndPagination
     * @return
     **/
    @PostMapping("/page")
    public Pagination<${className}DTO> page(@RequestBody ConditionAndPagination<${className}DTO> conditionAndPagination) {
        return this.${lowerCaseClassName}Service.page(conditionAndPagination);
    }

    /**
     * 根据ID删除
     *
     * @param id
     * @return
     **/
    @DeleteMapping("/{id}")
    public Boolean deleteById(@PathVariable("id") Long id) {
        this.${lowerCaseClassName}Service.deleteById(id);
        return true;
    }

    /**
     * 根据条件删除
     *
     * @param condition
     * @return
     **/
    @DeleteMapping("/condition")
    public Boolean deleteByCondition(@RequestBody ${className}DTO condition) {
        this.${lowerCaseClassName}Service.deleteByCondition(condition);
        return true;
    }

}